package com.drug.mingkang.service.impl;

import com.drug.mingkang.model.HqRawmaterialType;
import com.drug.mingkang.Mapper.HqRawmaterialTypeMapper;
import com.drug.mingkang.service.HqRawmaterialTypeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (HqRawmaterialType)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 11:28:44
 */
@Service("hqRawmaterialTypeService")
public class HqRawmaterialTypeServiceImpl implements HqRawmaterialTypeService {
    @Resource
    private HqRawmaterialTypeMapper hqRawmaterialTypeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param typeId 主键
     * @return 实例对象
     */
    @Override
    public HqRawmaterialType queryById(String typeId) {
        return this.hqRawmaterialTypeMapper.queryById(typeId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<HqRawmaterialType> queryAllByLimit(int offset, int limit) {
        return this.hqRawmaterialTypeMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param hqRawmaterialType 实例对象
     * @return 实例对象
     */
    @Override
    public HqRawmaterialType insert(HqRawmaterialType hqRawmaterialType) {
        this.hqRawmaterialTypeMapper.insert(hqRawmaterialType);
        return hqRawmaterialType;
    }

    /**
     * 修改数据
     *
     * @param hqRawmaterialType 实例对象
     * @return 实例对象
     */
    @Override
    public HqRawmaterialType update(HqRawmaterialType hqRawmaterialType) {
        this.hqRawmaterialTypeMapper.update(hqRawmaterialType);
        return this.queryById(hqRawmaterialType.getTypeId());
    }

    /**
     * 通过主键删除数据
     *
     * @param typeId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String typeId) {
        return this.hqRawmaterialTypeMapper.deleteById(typeId) > 0;
    }
}